package com.southwind.springboottest.study.java中流式操作;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
 * @description：TODO
 * @author： HXG
 * @create： 2024/3/19 15:09
 */
public class StreamDemo2 {
    public static void main(String[] args) {
        //1.单列集合获取Stream流
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"a","b","c","d","e");
        //获取到一条流水线，并把集合中的数据放到流水线上
        /*Stream<String> stream = list.stream();
        stream.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });*/
        list.stream().forEach(s -> System.out.println(s));
    }
}
